<script setup lang="ts">
const conditionFold = ref(true);
const conditionInitShowLength = 6;
const areConditionFold = () => {
  conditionFold.value = !conditionFold.value;
};
</script>

<template>
  <div class="header customDiv">
    <el-form
      ref="formRef"
      :inline="true"
      :model="formDataConfig"
      class="demo-form-inline"
    >
      <el-row>
        <el-col :span="6">
          <el-form-item label="查询逻辑">
            <el-select v-model="filtersLogic" placeholder="默认同时符合">
              <el-option label="同时符合" :value="0" />
              <el-option label="部分符合" :value="1" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col
          :span="6"
          v-for="(item, index) in formDataConfig.slice(
            0,
            conditionFold ? conditionInitShowLength : formDataConfig.length
          )"
          :key="item.key"
        >
          <el-form-item :label="item.label" :prop="`[${index}]value`">
            <el-date-picker
              v-if="item.type === 'date'"
              v-model="item.value"
              type="datetimerange"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              format="YYYY-MM-DD HH:mm:ss"
              date-format="YYYY/MM/DD ddd"
              time-format="A hh:mm:ss"
            />
            <el-input
              v-else-if="item.type === 'input' || !item.type"
              v-model="item.value"
              placeholder="请输入"
              clearable
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-button type="primary" @click="onSubmit(formRef)"
              >查询</el-button
            >
            <el-button type="primary" @click="resetForm(formRef)"
              >重置</el-button
            >
            <el-button
              v-if="formDataConfig.length > conditionInitShowLength"
              type="primary"
              link
              @click="areConditionFold"
            >
              {{ conditionFold ? "展开" : "收起" }}
              <el-icon v-if="conditionFold"><ArrowDown /></el-icon>
              <el-icon v-else><ArrowUp /></el-icon>
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
